// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: Code style modification
// ------------------------------------------------------------------

#include <xmlparser/data/XMLReaderProxyData.h>

namespace vbsutil {
namespace xmlparser {

ReaderProxyDataPart::ReaderProxyDataPart()
    : unicast_locators_size(0U),
      multicast_locators_size(0U),
      m_typeName(""),
      m_topicName(""),
      m_userDefinedId(0U),
      m_isAlive(true),
      m_topicKind(NO_KEY) {}

ReaderProxyDataPart::ReaderProxyDataPart(const ReaderProxyDataPart& readerInfo)
    : unicast_locators_size(readerInfo.unicast_locators_size),
      multicast_locators_size(readerInfo.multicast_locators_size),
      m_typeName(readerInfo.m_typeName),
      m_topicName(readerInfo.m_topicName),
      m_userDefinedId(readerInfo.m_userDefinedId),
      m_isAlive(readerInfo.m_isAlive),
      m_topicKind(readerInfo.m_topicKind) {}

ReaderProxyDataPart& ReaderProxyDataPart::operator=(const ReaderProxyDataPart& readerInfo) {
    unicast_locators_size = readerInfo.unicast_locators_size;
    multicast_locators_size = readerInfo.multicast_locators_size;
    m_typeName = readerInfo.m_typeName;
    m_topicName = readerInfo.m_topicName;
    m_userDefinedId = readerInfo.m_userDefinedId;
    m_isAlive = readerInfo.m_isAlive;
    m_topicKind = readerInfo.m_topicKind;
    return *this;
}

ReaderProxyDataPart::ReaderProxyDataPart(const size_t max_unicast_locators, const size_t max_multicast_locators)
    : unicast_locators_size(0U),
      multicast_locators_size(0U),
      remote_locators_(max_unicast_locators, max_multicast_locators),
      m_typeName(""),
      m_topicName(""),
      m_userDefinedId(0U),
      m_isAlive(true),
      m_topicKind(NO_KEY) {}

ReaderProxyDataPart::~ReaderProxyDataPart() {
    logDebug(RTPS_PROXY_DATA, "ReaderProxyDataPart destructor: " << m_guid << ", ReaderProxyDataPart info: " << *this;);
}

void ReaderProxyDataPart::add_unicast_locator(const Locator_t& locator) {
    remote_locators_.add_unicast_locator(locator);
}

void ReaderProxyDataPart::add_multicast_locator(const Locator_t& locator) {
    remote_locators_.add_multicast_locator(locator);
}

std::ostream& operator<<(std::ostream& os, const ReaderProxyDataPart& data) {
    os << "m_typeName: " << data.m_typeName << " m_topicName: " << data.m_topicName
       << " m_userDefinedId: " << data.m_userDefinedId << " m_isAlive: " << data.m_isAlive
       << " m_topicKind: " << data.m_topicKind << " m_entityId: " << data.m_userDefinedId;
    return os;
}

}  // namespace xmlparser
}  // namespace vbsutil
